
cmake_minimum_required(VERSION 3.10)

project(libShared)

add_library(libShared SHARED libShared.cpp)
target_compile_definitions(libShared PRIVATE DLL_EXPORT=1)
set_target_properties(libShared PROPERTIES DEBUG_POSTFIX "d")

install(FILES $<TARGET_PDB_FILE:libShared>
        $<TARGET_FILE:libShared>
#        $<TARGET_IMPORT_FILE:libShared> # from cmake 3.27
        $<TARGET_LINKER_FILE:libShared>
        ${CMAKE_CURRENT_SOURCE_DIR}/LibShared.hpp
#        DESTINATION LibShared/$<IF:$<CONFIG:Debug>,Debug,Release>
        DESTINATION "libShared"
        OPTIONAL COMPONENT libShared
        EXCLUDE_FROM_ALL #从默认的install中排除，需要使用--component libShared才会执行安装
)

# 安装 COMPONENT libShared
add_custom_command(
        TARGET libShared
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $<CONFIG> --component libShared)